//
//  CantripPluginProtocols.h
//  CantripSDK
//
//  Created by James Callender on Wed Apr 24 2002.
//  Copyright (c) 2001 James Callender. All rights reserved.
//

/*! @header CantripPluginProtocols.h
    @discussion Description forthcoming.
*/

#import <Cocoa/Cocoa.h>

/*!
@typedef WorldConnectionState
State values for a world connection window.
@abstract Description forthcoming.
@discussion Description forthcoming.
@constant WorldStartState State value before any connections have been made or attempted.
@constant WorldConnectingState State value while a connection is being attempted.
@constant WorldConnectedState State value while a connection is active.
@constant WorldDisconnectedState State value after a connection has been dropped.
*/
typedef enum _WorldConnectionState
{
    WorldStartState,
    WorldConnectingState,
    WorldConnectedState,
    WorldDisconnectedState
} WorldConnectionState;

/*!
@typedef WorldConnectionEvent
Constants for connection events.
@abstract Description forthcoming.
@discussion Discussion forthcoming.
@constant ConnectionDidDrop Description forthcoming.
@constant ConnectionUnsuccessful Description forthcoming.
@constant ConnectionTerminated Description forthcoming.
@constant ConnectionLoggedOff Description forthcoming.
*/
typedef enum _WorldConnectionEvent
{
    ConnectionSuccessful,
    ConnectionDidDrop,
    ConnectionUnsuccessful,
    ConnectionTerminated,
    ConnectionLoggedOff
} WorldConnectionEvent;


/*!
@typedef CantripPluginService
Constants for various plugin services.
@abstract Description forthcoming.
@discussion Description forthcoming.
@constant InterfaceEventService Interface event services.  Only keyEvents supported currently.
@constant ConnectionEventService Connection event services.
@constant DirtyServerStreamService Service for intercepting incoming server data.
@constant AttributedServerStreamService Service for intercepting cleaned server data.  ANSI color codes and other VT
		emulation codes have been stripped.
*/
typedef enum _CantripPluginService
{
    InterfaceEventService,
    ConnectionEventService,
    DirtyServerStreamService,
    AttributedServerStreamService,
} CantripPluginService;

/*!
@protocol CantripPluginClassProtocol
@abstract Protocol implemented by a plugin class.
@discussion Description forthcoming. 
*/
@protocol CantripPluginClassProtocol
+ (BOOL)initializeClass:(NSBundle *)theBundle;
+ (void)terminateClass;
+ (NSArray *)plugins;
+ (NSArray *)settingsModules;
@end

/*!
@protocol CantripPluginProtocol
@abstract Protocol implemented by a plugin class.
@discussion Description forthcoming. 
*/
@protocol CantripPluginProtocol
- (NSString *)pluginName;
- (NSString *)pluginVersion;
@end

/*!
@protocol CantripPluginProtocol
@abstract Required protocol implemented by a plugin module class.
@discussion Description forthcoming. 
*/
@protocol CantripSettingsModuleProtocol
- (NSString *)settingsDisplayName;
- (NSImage *)settingsDisplayIcon;
- (NSView *)settingsView;
- (NSSize)size;
- (void)updateForWorld:(id)world;
@end

@interface NSObject(CantripPluginModuleMethods)
- (void)applicationDidCreateUntitledWorld:(id)world;
- (void)applicationDidLoadWorld:(id)world;
- (void)applicationWillSaveWorld:(id)world;
- (void)applicationWillCloseWorld:(id)world;

- (void)windowControllerDidInitialize:(id)controller;
- (void)windowControllerWillClose:(id)controller;
@end

@interface NSObject(CantripPluginServiceMethods)
- (BOOL)handleInterfaceEventAction:(NSEvent *)event;
- (id)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdent willBeInsertedIntoToolbar:(BOOL)willBeInserted controller:(id)controller;
- (void)handleConnectionEventAction:(WorldConnectionEvent)event controller:(id)controller;
@end

@interface NSObject(CantripSettingsModuleMethods)
- (NSDictionary *)defaultWorldProperties;
- (NSSize)minSize;
- (NSSize)maxSize;
@end

@interface NSObject(CantripWorldControllerMethods)
- (void)sendString:(NSString *)str;
- (void)echoString:(NSString *)str;
- (void)sendStringAndEcho:(NSString *)str;
- (void)messageString:(NSString *)str;
- (void)connect;
- (void)disconnect;

- (void)enterPasswordMode:(id)sender;
@end

#define CantripPluginManager() [NSClassFromString(@"CantripPluginManager") sharedPluginManager]
#define CantripScriptManager() [NSClassFromString(@"CantripScriptManager") sharedScriptManager]
